Apparatus and method for realizing runtime system for programming language

ABSTRACT

Apparatus, method, and a program for causing a computer to function as an apparatus, for realizing a runtime system for programming language. The apparatus includes a storage unit for storing a first class that is an existing class in the object-oriented programming language, a second class that is a class that includes a member accessible from outside of the first class and is a class which is specialized for specific use; and a processing unit for performing processing using the second class with a predetermined instruction in software that realizes the runtime system, and performing processing using the first class with an instruction to check an identity of the second class in a user program product that is executed by the runtime system.

FIELD OF THE INVENTION

The present invention relates to an apparatus and a method for realizinga runtime system for a programming language. More particularly, thepresent invention relates to an apparatus and a method for realizing aruntime system for a class-based object-oriented programming language.

BACKGROUND

In a class-based object-oriented programming language, implementation ofan object is determined according to the class definition of therelevant object. Technology relating to classes in a class-basedobject-oriented programming language is known, as described in officialgazettes.

Japanese Patent Application JP11-85492A discloses technology accordingto which, first, a subclass creation unit creates a superclass includingan attribute and a method that are common to a selected plurality ofobjects. Next, common domains of objects designated for a subclass areretrieved from a domain keyword database to create a list of domainnames, and then, by means of objects selected from a non-common portion,the subclass creation unit creates a subclass from which attributes andmethods used in the superclass have been deleted, and thereaftercombines the created subclass with the superclass and deletes theselected objects from the non-common portion. Furthermore, a subclassmodel registration unit gives the subclass structure (combination modelof the superclass and subclass) created by the subclass creation unitthe same name as the superclass and registers the subclass structure ina domain model database as a domain model.

Thereafter, at a subclassing combination diagram generation unit, anobject group of subclass structures created by the subclass creationunit and an object group of non-common portions for which subclassingwas not performed are combined with a common portion extracted by asimilar portion extraction unit based on the respective related datathereof, and an object inclusion diagram having a subclassing structureis created.

Japanese Patent Application JP07-13766A discloses technology in whichSOMobjects, an IBM system object model product is an object-orientedframework, and the framework is constituted by classes and objectsbelonging to the classes. In SOMobjects, a class is itself an object,and has all the characteristics of an object. A class has the additionalcharacteristic of including information relating to a method or behavior(action) to which each object in the relevant class responds. In a casewhere an object includes a process code for a certain method name, theobject is regarded as an object that responds to the relevant method.When an object in a class responds to a certain method, the class isregarded as supporting the relevant method. The term “a method issupported by a certain class” refers to a method that is explicitlydefined for the class and a method that is inherited from a class thatis a parent class of the relevant class. Further, an object respondsonly to a method that is supported by the class to which the objectbelongs.

Japanese Patent Application JP06-103075A discloses technology accordingto which, by expanding an object-oriented programming language andsubclassing without indicating inheritance of implementation from aparent class, a modifier that indicates inheritance of an interface froma parent class of a class is provided for each class. Japanese PatentApplication JP2011-233171A discloses a class loader adapted to load aclass that is associated with an application. Japanese PatentApplication JP06-251163A discloses an object model display apparatusconfigured so that, when an instruction of a user that was input usingan input device is interpreted by an input interpretation unit and aninstruction is sent to a display unit and is displayed in a graphstructure on a display while referring to model information stored in anobject model storage unit via the display unit, a class is displayed asa node by a class node display unit, the relation is displayed as abranch by a related branch display unit, a member belonging to the classis displayed by a member display unit, and nodes corresponding torespective classes in a generalization/specialization relation, forexample, respective parent classes and child classes, are displayed sothat the parent class is included in the node of the child class by ageneralized class node display unit. Further, technology that optimizesa program by specializing is also known, as described in officialgazettes (for example, see Japanese Patent Applications JP2002-259135Aand JP2005-215830A).

Japanese Patent Application JP2002-259135A discloses a compiler thatincludes: an influence degree analysis unit that analyzes how much theexecution speed of a program that is a compilation object can beimproved by fixing a parameter of a predetermined instruction in theprogram in a specific state; a specialization data selection unit thatobtains statistics regarding the occurrence frequency in each state thatthe parameter of the instruction that is analyzed by the influencedegree analysis unit can take in a case where the program was executed,and determines which state to fix the parameter of the instruction inbased on the obtained statistical information; and a specializationprocessing unit that, based on the processing results obtained by theinfluence degree analysis unit and the specialization data selectionunit, generates a specialized path that fixes the parameter of thepredetermined instruction in a specific state in the program.

Japanese Patent Application JP2005-215830A discloses an optimizationcompiler that includes: an update instruction detection unit thatdetects an update instruction for updating the contents of a variable ora storage region designated by the variable in a program to beoptimized; an instruction string detection unit that detects aninstruction string for executing different processing in accordance withthe contents of the variable or the storage region when control istransferred by a control transfer instruction that transfers control toanother instruction string in the target program; an instruction stringcompiling unit that optimizes the detected instruction string forprocessing in a case where the contents of the variable or the storageregion are predetermined specific contents and compiles the instructionstring; and a setting instruction generation unit that, during a periodfrom an update instruction to a control transfer instruction in thetarget program, generates a setting instruction that is executed in acase where the contents of the variable or the contents of the storageregion are the specific contents and that sets a transfer destinationaddress of the control transfer instruction to the address of theinstruction string that was optimized by the instruction stringcompiling unit.

SUMMARY OF THE INVENTION

To achieve the aforementioned object, the present invention provides anapparatus for realizing a runtime system for a class-basedobject-oriented programming language, the apparatus including: a storageunit for storing a first class that is an existing class in theobject-oriented programming language, a second class that is a classthat includes a member that is accessible from outside of the firstclass and that is a class which is specialized for a specific use; and aprocessing unit for performing processing using the second class inaccordance with a predetermined instruction in software that realizesthe runtime system, and performing processing using the first class inaccordance with an instruction to check an identity of the second classin a user program that is executed by the runtime system.

The present invention also provides an apparatus for realizing a Java®runtime system, the apparatus including: a storage unit for storing afirst class that is an existing class in Java®, and a second class thatis a class that includes a member that does not have a private attributeof the first class and is a class in which a size of a field of thefirst class is reduced in accordance with a value stored in the firstclass; and a processing unit for processing a predetermined instructionin software that realizes the runtime system using the second class, andfor performing processing that returns information that the first classholds in accordance with any one of an “instanceof” bytecode and a“checkcast” bytecode that take an instance of the second class as anargument and a “Class.getName( )” method that takes the second class asan argument in a user program that is executed by the runtime system.

In addition, the present invention provides a method executed by acomputer for realizing a runtime system for a class-basedobject-oriented programming language, including the steps of: preparinga first class that is an existing class in the object-orientedprogramming language, and a second class that is a class that includes amember that is accessible from outside of the first class and that is aclass which is specialized for a specific use; performing processingusing the second class in accordance with a predetermined instruction insoftware that realizes the runtime system; and performing processingusing the first class in accordance with an instruction to check anidentity of the second class in a user program that is executed by theruntime system.

Furthermore, the present invention provides a program for causing acomputer to function as an apparatus for realizing a runtime system fora class-based object-oriented programming language, wherein the programcauses the computer to function as a storage unit for storing a firstclass that is an existing class in the object-oriented programminglanguage, and a second class that is a class that includes a member thatis accessible from outside of the first class and that is a class whichis specialized for a specific use; and a processing unit for performingprocessing using the second class in accordance with a predeterminedinstruction in software that realizes the runtime system, and performingprocessing using the first class in accordance with an instruction tocheck an identity of the second class in a user program that is executedby the runtime system.

According to the present invention, the implementation of an object canbe made more efficient while retaining compatibility with existingsoftware.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a view illustrating an example of the hardware configurationof a computer in an embodiment of the present invention;

FIG. 2 is a block diagram illustrating an example of the functionalconfiguration of the computer in an embodiment of the present invention;

FIG. 3A illustrates the implementation of the existing java.lang.Stringclass, a “value” field points to a char type array, and a 16-bitcharacter string of an arbitrary length is stored in the array;

FIG. 3B, Variant #1, illustrates the implementation of a field with asize of 32 bits×2 and to store “length” (described as “Len” in thefigure) and “a”, “b”, “c”, “d” in this field;

FIG. 3C, Variant #2, illustrates the implementation of a field with asize of 32 bits×4 and to store “length” (described as “Len” in thefigure) and “a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i” in this field;

FIG. 3D, Variant #3, illustrates the implementation of a field with asize of 32 bits×6 and to store “length” (described as “Len” in thefigure) and “a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “j”, “k”, “l”,“m”, “n”, “o”, “p” in this field;

FIG. 3E, Variant #4, illustrates the implementation of a field with asize of 32 bits×6 is prepared and to store “length” (described as “Len”in the figure) and the number of bits (“bits”) in the 16 bits in thefirst half of the first field and to store binary data corresponding toa character string from the 16 bits in the second half of the firstfield to the sixth field;

FIG. 3F, Variant #5, illustrates the implementation of field with a sizeof 32 bits×2 and to store “length” (described as “Len” in the figure)and “−1”, “23”, “45”, “6.”, “78” in this field;

FIG. 3G, Variant #6, illustrates the implementation of a field with asize of 32 bits×4 and to store “length” (described as “Len” in thefigure) and “+8”, “1−”, “3−”, “12”, “34”, “−5”, “67”, “8” in this field;

In FIG. 4A, illustrates the implementation of a “digits” field points toan int type array, and a bit string of an arbitrary length is stored inthe array;

FIG. 4B, Variant #1, illustrates the implementation of a “numLength”(described as “numLen” in the figure) and “1stNonzeroDigit” (describedas “Non0Digit” in the figure) in a 32-bit size field;

FIG. 4C, Variant #2, illustrates the implementation of two 32-bit sizefields and store the 63^(rd) to 32^(nd) bits in the first field andstore the 31^(st) to 0^(th) bits in the second field;

FIG. 4D, Variant #3, illustrates the implementation of four 32-bit sizefields, storing the 127^(th) to 96^(th) bits in the first field, storingthe 95^(th) to 64^(th) bits in the second field, storing the 63^(rd) to32^(nd) bits in the third field, and store the 31^(st) to 0^(th) bits inthe fourth field;

FIG. 5A, illustrates the implementation of “intVal” field that shows abit string that cannot be represented by a long type points and a“smallValue” field that shows a bit string that can be represented by along type;

FIG. 5B, Variant #1, illustrates the implementation of storing a bitstring having a bit length that is equal to or greater than 32;

FIG. 5C, Variant #2, illustrates the implementation of storing a bitstring having a bit length shorter than 32;

FIG. 6 is a flowchart illustrating an example of operations whencreating a JVM object in an embodiment of the present invention;

FIG. 7 is a flowchart illustrating an example of operations at the timeof a garbage collection process of a JVM in the present embodiment;

FIG. 8 is a flowchart illustrating an example of operations whenproviding class meta information of a JVM in the present embodiment; and

FIG. 9 is a view showing effects obtained by the embodiment of thepresent invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Hereunder, an embodiment of the present invention is described in detailwith reference to the accompanying drawings.

FIG. 1 is a view illustrating an example of the hardware configurationof a computer 10 in the present embodiment. As shown in FIG. 1, thecomputer 10 is constituted by connecting a CPU 11, a RAM (random accessmemory) 12, a HDD (hard disk drive) 13, a keyboard 14, a mouse 15, adisplay 16 and a communication interface 17 using a system bus 18.

The CPU 11 is preferably based on a 32-bit or 64-bit architecture,although is not limited thereto. Examples of such architecture that arefavorably used include POWERB™ and POWER7™ from IBM Corporation, Core™i3, Core™ i5, Core™ i7, and Xeon® from Intel Corporation, and Athlon™,Phenom™, and Sempron™ from Advanced Micro Devices Incorporated. The RAM12 is preferably a memory that has a capacity of 8 GB or more, and morepreferably a capacity of 16 GB or more, although the RAM 12 is notlimited thereto. The HDD 13 stores an OS (operating system). The OS canbe an arbitrary OS that is adapted for the CPU 11. For example, Linux®,AIX® from IBM Corporation, Windows® 7, Windows® 8, or Windows® 2003server from Microsoft Corporation, and Mac OS® from Apple Incorporatedcan be used. The HDD 13 also stores a program for causing the computer10 to operate as a webserver, such as WebSphere® application server fromIBM Corporation. The program is loaded into the RAM 12 upon startup ofthe computer 10.

The keyboard 14 and mouse 15 are used for operating a graphic objectsuch as an icon, a taskbar or a text box that is displayed on thedisplay 16 in accordance with a graphic user interface that the OSprovides. The display 16 is preferably a 32-bit true color LCD monitorhaving a resolution of 1024×768 or more, although the display 16 is notlimited thereto. The display 16 is used for displaying results ofoperations by various programs.

The communication interface 17 is preferably connected to a network bythe Ethernet® protocol, although the communication interface 17 is notlimited thereto. The communication interface 17 receives a processingrequest in accordance with a communication protocol such as TCP/IP bymeans of a function that WebSphere® application server or the likeprovides from a client computer (not illustrated in the drawings), orreturns a processing result to a client computer (not illustrated in thedrawings).

A case will now be considered in which the computer 10 illustrated inFIG. 1 executes a program described by a class-based object-orientedprogramming language. In this case, according to the present embodimenta group of classes having an independent implementation is introduced,although the class group is handled as the same class from a userprogram. That is, a class group having a plurality of implementationsthat the computer 10 provides is prepared with respect to an existingclass. In the present specification, the existing class is referred toas a “representative class” that defines an external interface. Further,a class having an implementation other than that of a representativeclass is referred to as a “specialized class”.

In this case, it is assumed that the following relations exist between arepresentative class and a specialized class with respect thereto. Afirst relation is that although a subclass of a specialized class cannotbe created, a specialized class can be newly created with respect to asubclass of a representative class. A second relation is that arepresentative class and specialized class group can access all membersof one another. More specifically, it is possible for a representativeclass to access all members of a specialized class and it is possiblefor a specialized class to access all members of a representative class,and it is possible for a specialized class with respect to arepresentative class to access all members of other specialized classes(specialized classes in a fraternal relation) with respect to therepresentative class. The second relation also includes a relation thatthe specialized class is invisible from a class other than a class inthe representative class and specialized class group. Further, thedefinition of a variable and a method of a specialized class is assumedto satisfy the following constraints so that an anomaly does not arisebetween a representative class and a specialized class with respectthereto.

A first constraint is that when a class variable that exists in arepresentative class is referenced with a specialized class, the classvariable of the representative class is always referenced. A memory areathat stores class variables is shared by the representative class andall the specialized classes.

A second constraint is that a non-private instance variable is arrangedwith the same layout for the entire representative class and specializedclass group. The memory arrangement of an instance variable other than aprivate instance variable is made the same for the representative classand all of the specialized classes.

Therefore, based on the first constraint and the second constraint itcan be said that a variable other than a private instance variable isthe same for a representative class and a specialized class. A thirdconstraint is that a non-private instance method has the same methodtable index for the entire representative class and specialized classgroup. A fourth constraint is that a variable or a method that exists ina representative class can be deleted with a specialized class only in acase where the relevant variable or method is private. That is, anon-private variable that exists in a representative class cannot bedeleted, and a non-private method that exists in a representative classcannot be deleted. Note that it is possible to add a variable or amethod in a specialized class.

In a class-based object-oriented programming language, implementation ofan object is determined in accordance with the class definition of therelevant object. For example, the layout on a memory of an object isalso determined in accordance with the class definition of the object.Therefore, a region for storing variables of an object is allocated at aposition on the memory that is determined according to the classdefinition. However, there are also cases in which some variables of anobject are not used depending on the values of the variables, and insuch a case the memory usage amount can be reduced by adopting aconfiguration so that a region for storing the relevant variables is notallocated on the memory.

When it is desired to hold a plurality of object layouts for a singleclass in this manner, for example, according to Java®, an interface isused. However, when the implementation of a class, such as the Java®system class, that is already being used by many kinds of software ischanged, the existing software will no longer operate. Further, if achange is made that alters external specifications with respect to theJava® system class, the compatibility as Java® will not be maintained.Although there are languages that can have unique classes for eachobject, such as the eigenclass of Ruby or a template-based languageimplementation such as JavaScript®, it is necessary for the programmerto explicitly use the unique classes for different purposes, and theclasses cannot be used for optimizing existing code. There has been ademand to optimize the memory layout of objects while maintainingcompatibility with existing software. In more general terms, there hasbeen a demand to make the implementation of objects more efficient whilemaintaining compatibility with existing software. However, this demandhas not been adequately satisfied. Note that, although the technologydisclosed in Patent Japanese Patent Applications JP11-85492A,JP07-13766A, JP06-103075A, JP2011-233171A, and JP06-251163A relate toclasses in a class-based object-oriented programming language, thetechnology disclosed in Patent Japanese Patent Applications JP11-85492A,JP07-13766A, JP06-103075A, JP2011-233171A does not suggest means forsolving the problem described above. Further, although the respectivetechnologies disclosed in Patent Japanese Patent ApplicationsJP2002-259135A and JP2005-215830A optimize a program, these technologiescan also not solve the above described problem. An object of the presentinvention is to make the implementation of objects more efficient whilemaintaining compatibility with existing software.

The processing unit can include: a first processing unit for performingprocessing using the second class in accordance with a predeterminedinstruction in the software that realizes the runtime system; and asecond processing unit for performing processing using the first classin accordance with an instruction to check an identity of the secondclass in the user program that is executed by the runtime system.

In the aforementioned apparatus, if a class variable included in thesecond class is also included in the first class, the second class canrefer to a class variable included in the first class as a classvariable that is included in the second class. Further, as an instancevariable that is accessible from outside the second class, the secondclass can include an instance variable with respect to which a relativearrangement position in the second class is identical to a relativearrangement position in the first class. In addition, as an instancemethod that is accessible from outside the second class, the secondclass can include an instance method with respect to which an index in amethod table of the second class is identical to an index in a methodtable of the first class. Further, in the aforementioned apparatus, thepredetermined instruction can be an instruction to generate an instanceof a class group including the first class and the second class; and thefirst processing unit can generate an instance of the second class in acase where it can be determined that the second class is appropriatebased on a value stored in the instance to be created, and can generatean instance of the first class in a case where it cannot be determinedthat the second class is appropriate based on a value stored in theinstance to be created. In addition, the predetermined instruction canbe an instruction to perform a garbage collection with respect to amemory for storing an instance of the first class, and the firstprocessing unit can convert an instance of the first class to aninstance of the second class in a case where it can be determined thatthe second class is appropriate based on a value stored in the firstclass.

According to the present embodiment, when creating an object of a class,a representative class or any specialized class is selected based on aninitial value. In a case where an appropriate implementation can bedetermined based on an initial value, an instance of a specialized classwith respect to the implementation is created. In contrast, in a casewhere an appropriate implementation cannot be determined based on aninitial value, an instance of a representative class is created.Alternatively, when performing a garbage collection process, an instanceof the representative class can be changed to an instance of anappropriate specialized class, or an instance of a specialized class canbe changed to an instance of a more appropriate specialized class. Forexample, if the garbage collection is a copying scheme, an instance ischanged in the above described manner when copying an object. Further,if the garbage collection is a mark-and-sweep scheme, an instance ischanged in the above described manner when performing compaction.

In the present embodiment, the runtime system always returns class metainformation of the representative class in a case where the user programreferences class meta information (for example, identity information ofthe class). More specifically, with respect to an instruction such as an“instanceof” bytecode, a “checkcast” bytecode and a “Class.getName( )”method, even in a case where a specialized class was passed as anargument, operations are performed as though a representative class waspassed, and therefore the class meta information of the representativeclass is always returned. It is thereby possible to hide the existenceof a specialized class from the user program.

Hereunder, a case is described in which a Java® virtual machine(hereunder, referred to as “JVM”) is taken as an example of the runtimesystem. FIG. 2 is a view illustrating an example of a functionalconfiguration for performing the above described operations of thecomputer 10 illustrated in FIG. 1. As shown in FIG. 2, the computer 10includes a class file storage unit 20 and a JVM 30. The class filestorage unit 20 stores class files that are files with the extension“.class” and that include Java® bytecode that is executable on the JVM30. A class file of a representative class (hereunder, referred to as“representative class file”) 41, and a class file of a specialized class(hereunder, referred to as “specialized class file”) 42 are stored. Thefile name of the representative class file 41 is taken as “C.class” andthe file name of the specialized class file 42 is taken as “Cx.class”.The class file storage unit 20 is realized by means of, for example, theHDD 13 (see FIG. 1).

The JVM 30 is software that is executed after being converted to thenative code of a platform onto which Java® bytecode was ported.Therefore, although the JVM 30 is software, in this case, forconvenience the apparatus on which the software operates is described asthe JVM 30. According to the present embodiment the JVM 30 is providedas one example of an apparatus that realizes a runtime system for anobject-oriented programming language. The JVM 30 also includes a classdata area 31 and a heap area 32. In addition, the JVM 30 includes aninterpreter 33, a JIT (just-in-time) compiler 34, a machine instruction35, a class loader 36, an object allocator 37 and a garbage collector38.

The class data area 31 stores a class that was loaded from a class filestored in the class file storage unit 20. In this case, first, a classincluding a method that is a target for execution by the interpreter 33or for compilation by the JIT compiler 34 is taken as a class 50. Notethat, hereunder, this kind of method is also referred to as a “userprogram”. The classes that are called when the interpreter 33 executesthe method or when the machine instruction 35 obtained as a result ofthe JIT compiler 34 compiling the method is executed are taken to be arepresentative class 51 and a specialized class 52. In this case, sincethe file name of the representative class file 41 is “C.class” and thefile name of the specialized class file 42 is “Cx.class”, therepresentative class 51 is taken as class C and the specialized class 52is taken as class Cx. In the present embodiment, the representativeclass 51 is used as an example of a first class that is an existingclass, and the specialized class 52 is used as an example of a secondclass that is a class which is specialized for a specific use. Further,the class data area 31 is provided as an example of a storage unit forstoring the first class and the second class.

The respective classes include metadata, a class variable, and a method.The metadata includes a class name of the relevant class, informationrelating to an instance variable of the class (for example, an offset ofan instance variable), and a method table for calling an instance methodof the class. Further, as described above, there is the first constraintthat, when a class variable that exists in a representative class isreferenced with a specialized class, the class variable of therepresentative class is always referenced. Accordingly, a class variablethat exists in the representative class 51 does not exist in thespecialized class 52. In FIG. 2, this fact is indicated by greying out aclass variable inside the specialized class 52. In addition, asdescribed above, there is the third constraint that a non-privateinstance method has the same method table index for the entirerepresentative class and specialized class group. Because the classmethod of the representative class 51 is referenced when a class methodthat exists in the representative class 51 is referenced with thespecialized class 52, a class method that exists in the representativeclass 51 does not exist in the specialized class 52. On the other hand,in some cases an instance method exists in both the representative class51 and the specialized class 52. Accordingly, in FIG. 2, a method insidethe specialized class 52 is not grayed out.

The heap area 32 stores objects of classes that are stored in the classdata area 31. In this case, an object (hereunder, referred to as“representative class object”) 61 of the representative class that wascreated by the object allocator 37 based on the representative class 51,and an object (hereunder, referred to as “specialized class object”) 62of the specialized class that was created by the object allocator 37based on the specialized class 52 are stored.

The objects of the respective classes include information identifyingthe class and information of an instance variable. In this case, asdescribed above, there is the fourth constraint that a variable or amethod that exists in a representative class can only be deleted with aspecialized class in a case where the relevant variable or method isprivate. Accordingly, although “public_field1” that is a non-privateinstance variable that exists in the representative class object 61exists in the specialized class object 62, “private_field2” that is aprivate instance variable that exists in the representative class object61 does not exist in the specialized class object 62. Furthermore, asdescribed above, there is the second constraint that a non-privateinstance variable is arranged with the same layout for the entirerepresentative class and specialized class group. Accordingly,“public_field1” that is a non-private instance variable is arrangedfirst in both of the representative class object 61 and the specializedclass object 62. Note that, as described above, since it is possible toadd a variable in a specialized class, “private_fieldX” that is aprivate instance variable that does not exist in the representativeclass object 61 exists in the specialized class object 62.

The interpreter 33 is a program for executing a method of a class storedin the class data area 31 while successively interpreting the method. Inthis case, an example is illustrated in which, by executing a method ofthe class 50, the class loader 36 is requested to load therepresentative class 51 or the specialized class 52, and the objectallocator 37 is requested to create the representative class object 61or the specialized class object 62. Further, this example alsoillustrates the fact that when an instruction to check the identity ofthe representative class 51 or the specialized class 52 is detected as aresult of executing the method of the class 50, the class loader 36 isrequested to perform the relevant check, and the result of the check isreceived.

The JIT compiler 34 is a program for compiling a method of a classstored in the class data area 31 immediately prior to execution, andconverting the method to the machine instruction 35. In this case, anexample is illustrated in which a method of the class 50 is converted.

The machine instruction 35 is a series of instructions that the JITcompiler 34 generates by converting a method and that the CPU 11 (seeFIG. 1) directly executes. In this case, an example is illustrated inwhich, by execution of the machine instruction 35, the class loader 36is requested to load the representative class 51 or the specializedclass 52, and the object allocator 37 is requested to create therepresentative class object 61 or the specialized class object 62.Further, this example also illustrates the fact that when an instructionto check the identity of the representative class 51 or the specializedclass 52 is detected as a result of executing the machine instruction35, the class loader 36 is requested to perform the relevant check, andthe result of the check is received.

Upon receiving a request to load a class from the interpreter 33 or themachine instruction 35, the class loader 36 checks whether or not therelevant class is already loaded in the JVM 30. If the relevant class isnot yet loaded in the JVM 30, the class loader 36 loads the relevantclass into the JVM 30 from the class files stored in the class filestorage unit 20. Note that, the representative class 51 and thespecialized class 52 are available as classes to be loaded in this case.If the class loader 36 is requested by the interpreter 33 or the machineinstruction 35 to check the identity of the representative class 51 orthe specialized class 52, the class loader 36 performs the relevantcheck. The class loader 36 then returns the result of the check to theinterpreter 33 or the machine instruction 35. Note that, at such time,even if the class loader 36 was requested to check the identity of thespecialized class 52, the class loader 36 returns the information of therepresentative class 51 to the interpreter 33 or the machine instruction35. In the present embodiment the class loader 36 is provided as oneexample of a second processing unit for performing processing inaccordance with an instruction to check the identity of a class in auser program that is executed by a runtime system for an object-orientedprogramming language.

Upon receiving a request to create an object of a class from theinterpreter 33 or the machine instruction 35, the object allocator 37creates the relevant object of a class based on a class that is storedin the class data area 31. At such time, the object allocator 37 createsthe relevant object of a class based on a class that is determined bythe interpreter 33 or the machine instruction 35 among therepresentative class 51 and the specialized class 52. The objectallocator 37 stores the created object in the heap area 32. In thepresent embodiment the object allocator 37 is provided as one example ofa first processing unit for performing processing in accordance with apredetermined instruction in software that realizes a runtime system foran object-oriented programming language.

The garbage collector 38 performs a garbage collection process that deallocates areas in which objects that are no longer required were storedin the heap area 32. At such time, the representative class object 61 isconverted to an object of a specialized class, or the specialized classobject 62 is converted to an object of a different specialized class. Inthe present embodiment the garbage collector 38 is provided as oneexample of a first processing unit for performing processing inaccordance with a predetermined instruction in software that realizes aruntime system for an object-oriented programming language.

An implementation technique when the class loader 36 performs variablename resolution in the present embodiment will now be described indetail. First, name resolution with respect to a class variable will bedescribed. When a class variable that exists in the representative class51 is referenced by the specialized class 52, the class loader 36 alwaysacquires the address of the class variable of the representative class51. Further, when a private class variable that was added by thespecialized class 52 is referenced, the class loader 36 acquires theaddress of the unique class variable of the specialized class 52.

Next, name resolution with respect to an instance variable will bedescribed. The class loader 36 operates so that an offset of anon-private instance variable that exists in the representative class 51becomes the same as an offset of the relevant instance variable in thespecialized class 52. That is, the class loader 36 stores the sameoffset information in the metadata of the representative class 51 and ofthe specialized class 52. By this means, when the object allocator 37stores an object in the heap area 32, instance variables are collectedand disposed at the start of the object with the same offset in therepresentative class 51 and the specialized class 52. Further, when aprivate instance variable that exists in the representative class 51 isreferenced by the specialized class 52, the class loader 36 storesinformation of a uniquely determined offset in the metadata of thespecialized class 52. In addition, when a private variable that wasadded by the specialized class 52 is referenced also, the class loader36 stores information of a uniquely determined offset in the metadata ofthe specialized class 52.

An implementation technique when the class loader 36 performs methodname resolution in the present embodiment will now be described indetail. First, name resolution with respect to a class method will bedescribed. When a class method that exists in the representative class51 is referenced by the specialized class 52, the class loader 36acquires the address of the unique class method of the specialized class52. However, in a case where the specialized class 52 shares a classmethod of the representative class 51, the class loader 36 acquires theaddress of the method of the representative class 51.

Next, name resolution with respect to a virtual method among theinstance methods will be described. The class loader 36 operates so thatan index of a method table for calling a virtual method that exists inthe representative class 51 and an index of a method table for callingthe relevant virtual method in the specialized class 52 become the same.The class loader 36 stores the address of the method in the same indexof a method table in the metadata of the representative class 51 and ofthe specialized class 52. When referencing a method that was added bythe specialized class 52, the class loader 36 stores the address of theadded method after the address of the method that exists in therepresentative class 51, in the method table in the metadata of thespecialized class 52.

Name resolution with respect to a final method among the instancemethods will be described below. Although in the original implementationof a JVM the class loader 36 acquires an address, in the presentembodiment the class loader 36 performs similar operations as whenperforming name resolution with respect to a virtual method. The reasonis that although in the original implementation of a JVM there is onlyone final method in the system, according to the present embodiment thefinal method can have a different implementation between therepresentative class 51 and the specialized class 52. Optimization ofthe interpreter 33 or the JIT compiler 34 is limited to allow aplurality of implementations of a class method and a final method toexist on the JVM 30.

An implementation technique for adjusting addresses of classes toimprove efficiency in the present embodiment will now be described indetail. First, loading of classes by the class loader 36 will bedescribed. The class loader 36 loads the specialized class 52 in anaddress range that is different to that for a normal class. At suchtime, the class loader 36 adjusts the addresses to which classes areloaded so that bit operations can be utilized. More specifically, theclass loader 36 makes the high-order N bits of the address to which therepresentative class 51 is loaded and the high-order N bits of alladdresses to which the specialized classes 52 are loaded the same.Further, the specialized classes 52 can be distinguished by lower-orderM bits that follow the high-order N bits. Note that, at this time, it issufficient to set 0 for all the lower-order M bits of the address towhich the representative class 51 is loaded. Further, 0 is set for allthe lower-order bits that come after the high-order N bits and thesubsequent lower-order M bits. In this way, with respect to aninstruction such as an “instanceof” bytecode, a “checkcast” bytecode oran “Class.getName( )” method, it is possible to return class metainformation of the representative class 51 using only the high-order Nbits of the address to which the class was loaded. Further, with respectto a request to access a class variable, by performing processing thattakes out only the high-order N bits of the address to which the classwas loaded and references the memory using the index from there, a classvariable of the representative class 51 will always be accessed.

Next, storage of the machine instruction 35 by means of the JIT compiler34 will be described. As an area for storing the machine instruction 35,the JIT compiler 34 allocates an area in which a number of fixed-lengthareas that correspond to the number of specialized classes 52 arelinked. At such time, an offset of the fixed-length areas with respectto the specialized classes 52 is calculated based on the portion of Mbits of the addresses of the specialized classes 52. More specifically,for each method, the JIT compiler 34 allocates a number of linked areasthat correspond to the number of all of the specialized classes 52.Since the number of the specialized classes 52 is previously known, itis possible for the JVM 30 to allocate a continuous area. The code of amethod of the specialized class 52 can be calculated by adding a valueobtained by appropriately shifting the portion of M bits of the addressof the specialized class 52 to an address acquired from the method tableof the representative class 51. Accordingly, the method can be calledfaster than a virtual call with respect to which it is required to loadthe address. Note that when a code does not fit within the fixed-lengtharea, it is sufficient to appropriately jump to a different area.

FIGS. 3A-3G are views that illustrate a first example of therepresentative class 51 and specialized classes 52. In this firstexample, the existing java.lang.String class is taken as therepresentative class 51, and seven specialized classes 52 are introducedwith respect to the representative class 51.

FIG. 3A illustrates the implementation of the existing java.lang.Stringclass. According to this implementation, a “value” field points to achar type array, and a 16-bit character string of an arbitrary length isstored in the array. However, with this implementation, if the characterstring is not long, there will be wastage in the array, and there willalso be wastage in the respect that information such as the size of thearray must be stored as a result of preparing the array. Further, theexisting java.lang.String class has an “offset” field to facilitatetrimming of part of the 16-bit character string that is stored in thearray, and since this field is often not used, there are also cases inwhich providing this field constitutes wastage.

For example, let us consider a case of storing “abcd” that is an 8-bitcharacter string in which the length of the character string is 7 orless. In this case, as shown in the implementation of a Variant #1 inFIG. 3B, it is sufficient to prepare a field with a size of 32 bits×2and to store “length” (described as “Len” in the figure) and “a”, “b”,“c”, “d” in this field.

Further, let us consider a case of storing “abcdefghi” that is an 8-bitcharacter string in which the length of the character string is 15 orless. In this case, as shown in the implementation of a Variant #2 inFIG. 3C, it is sufficient to prepare a field with a size of 32 bits×4and to store “length” (described as “Len” in the figure) and “a”, “b”,“c”, “d”, “e”, “f”, “g”, “h”, “i” in this field.

In addition, let us consider a case of storing “abcdefghijklmnop” thatis an 8-bit character string in which the length of the character stringis 23 or less. In this case, as shown in the implementation of a Variant#3 in FIG. 3D, it is sufficient to prepare a field with a size of 32bits×6 and to store “length” (described as “Len” in the figure) and “a”,“b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “j”, “k”, “l”, “m”, “n”, “o”,“p” in this field.

On the other hand, let us consider a case of storing a hexadecimalcharacter string or a character string encoded with Base64 up to 176bits. In this case, as shown in the implementation of a Variant #4 inFIG. 3E, a field with a size of 32 bits×6 is prepared. Further, it issufficient to store “length” (described as “Len” in the figure) and thenumber of bits (“bits”) in the 16 bits in the first half of the firstfield and to store binary data corresponding to a character string fromthe 16 bits in the second half of the first field to the sixth field.

Further, let us consider a case of storing “−123456.78” that is composedof a packed decimal string up to 14 digits and a standard symbol that isused together therewith. In this case, as shown in the implementation ofa Variant #5 in FIG. 3F, it is sufficient to prepare a field with a sizeof 32 bits×2 and to store “length” (described as “Len” in the figure)and “−1”, “23”, “45”, “6.”, “78” in this field.

In addition, let us consider a case of storing “+81−3−1234−5678” that iscomposed of a packed decimal string up to 30 digits and a standardsymbol that is used together therewith. In this case, as shown in theimplementation of a Variant #6 in FIG. 3G, it is sufficient to prepare afield with a size of 32 bits×4 and to store “length” (described as “Len”in the figure) and “+8”, “1−”, “3−”, “12”, “34”, “−5”, “67”, “8” in thisfield.

FIGS. 4A-4D are views that illustrate a second example of therepresentative class 51 and specialized classes 52. In this secondexample, the existing java.math.BigInteger class is taken as therepresentative class 51, and three specialized classes 52 are introducedwith respect to the representative class 51.

The implementation of the existing java.math.BigInteger class isillustrated in FIG. 4A. According to this implementation, a “digits”field points to an int type array, and a bit string of an arbitrarylength is stored in the array. However, with this implementation, if thebit string is not long, there will be wastage in the array, and therewill also be wastage in the respect that information such as the size ofthe array must be stored as a result of preparing the array. Further,the existing java.math.BigInteger class has a “numLength” field thatshows the bit length and a “1stNonzeroDigit” field that shows the lengthuntil a first bit other than 0 appears, and consequently there iswastage with respect to these fields also in a case where the bit stringis not long. For example, let us consider a case of storing a bit stringhaving a bit length shorter than 2¹⁵. In this case, as shown in theimplementation of a Variant #1 in FIG. 4B, it is sufficient to include“numLength” (described as “numLen” in the figure) and “1stNonzeroDigit”(described as “Non0Digit” in the figure) in a 32-bit size field.Further, let us consider a case of storing a bit string having a bitlength shorter than 64. In this case, as shown in the implementation ofa Variant #2 in FIG. 4C, it is sufficient to prepare two 32-bit sizefields and store the 63^(rd) to 32^(nd) bits in the first field andstore the 31^(st) to 0^(th) bits in the second field. In addition, it issufficient to include “numLength” (described as “numLen” in the figure)and “1stNonzeroDigit” (described as “Non0Digit” in the figure) in a32-bit size field.

Next, let us consider a case of storing a bit string having a bit lengthshorter than 128. In this case, as shown in the implementation of aVariant #3 in FIG. 4D, it is sufficient to prepare four 32-bit sizefields and store the 127^(th) to 96^(th) bits in the first field, storethe 95^(th) to 64^(th) bits in the second field, store the 63^(rd) to32^(nd) bits in the third field, and store the 31^(st) to 0^(th) bits inthe fourth field. In addition, it is sufficient to include “numLength”(described as “numLen” in the figure) and “1stNonzeroDigit” (describedas “Non0Digit” in the figure) in a 32-bit size field.

FIGS. 5A-5C are views that illustrate a third example of therepresentative class 51 and specialized classes 52. In this thirdexample, the existing java.math.BigDecimal class is taken as therepresentative class 51, and two specialized classes 52 are introducedwith respect to the representative class 51.

The implementation of the existing java.math.BigDecimal class isillustrated in FIG. 5A. According to this implementation, an “intVal”field that shows a bit string that cannot be represented by a long typepoints to the implementation of the existing java.math.BigInteger classthat is shown in FIG. 4A, and a “smallValue” field that shows a bitstring that can be represented by a long type is also provided. However,according to this implementation, there will be wastage in the array ina case where a numerical value can be represented by a long type, andthere will also be wastage in the respect that information such as thesize of the array must be stored as a result of preparing the array.

For example, let us consider a case of storing a bit string having a bitlength that is equal to or greater than 32. In this case, as shown inthe implementation of a Variant #1 in FIG. 5B, the “smallValue” fieldneed not be provided. Note that, in this case “bigInt” is adopted for“intVal” in FIG. 5A.

Further, let us consider a case of storing a bit string having a bitlength shorter than 32. In this case, as shown in the implementation ofa Variant #2 in FIG. 5C, the “intVal” field need not be provided. Notethat, in this case “smallValueInt” is adopted for “smallValue” in FIG.5A.

FIG. 6 is a flowchart illustrating an example of operations of the JVM30 when creating an object in the present embodiment. Note that thisoperation example is started when the interpreter 33 or the machineinstruction 35 detect an instruction to create an object of a classgroup including the representative class 51 and the specialized class 52from a user program (for example, a method of the class 50). Thus,although according to the present embodiment operations are started as aresult of the interpreter 33 or the machine instruction 35 detecting aninstruction, hereunder, operations of the JVM 30 are described on theassumption that the operations start as a result of the interpreter 33detecting an instruction.

When the operations start, in the JVM 30, first the interpreter 33determines whether or not an initial value of the object to be created(creation object) is known (step 301). This determination can beperformed, for example, by analyzing the portions before and after theinstruction to create an object of the user program. If it is determinedthat the initial value of the creation object is known, the interpreter33 determines whether or not the class of the creation object has thespecialized classes 52 (step 302). This determination can be performed,for example, by checking whether or not the specialized classes 52 arestored at other addresses having the same high-order N bits as thehigh-order N bits of the address of the representative class 51.

If it is determined that the class of the creation object has thespecialized classes 52, the interpreter 33 retrieves the specializedclasses 52 of the creation object based on the initial value which wasdetermined as being known in step 301 (step 303). Next, the interpreter33 determines whether or not there is an appropriate specialized class52 (step 304). For example, as shown in FIG. 3B, if it is known that theinitial value is “abcd”, the interpreter 33 adopts the specialized class52 of the Variant #1 of the java.lang.String class as the appropriatespecialized class 52. If it is determined as a result that there is anappropriate specialized class 52, the interpreter 33 sets the relevantspecialized class 52 in the class of the creation object (step 305).

In contrast, if it is not determined that the initial value of thecreation object is known in step 301, if it is not determined that theclass of the creation object has the specialized classes 52 in step 302,or if it is not determined that there is an appropriate specializedclass 52 in step 304, the interpreter 33 sets a class designated by theuser program in the class of the creation object (step 306).

Next, in the JVM 30, the class loader 36 determines whether or not theclass designated by the user program is already loaded in the class dataarea 31 (step 307). If it is determined that the class designated by theuser program is already loaded in the class data area 31, the processingproceeds directly to step 309. On the other hand, if it is notdetermined that the class designated by the user program is alreadyloaded in the class data area 31, the class loader 36 loads the relevantclass into the class data area 31 (step 308).

Next, the class loader 36 determines whether or not a specialized class52 was set in step 305 but the relevant specialized class 52 is not yetloaded in the class data area 31 (step 309). In step 309, if the classloader 36 determines that the specialized class 52 was not set in step305 or that the specialized class 52 that was set in step 305 is alreadyloaded in the class data area 31, the processing proceeds directly tostep 311. In contrast, if it is determined that the specialized class 52was set in step 305 but the specialized class 52 is not yet loaded inthe class data area 31, the class loader 36 loads the relevantspecialized class 52 in the class data area 31 (step 310). Thereafter,in the JVM 30, the object allocator 37 allocates a memory area forstoring an object of the class that was set in step 305 or step 306(step 311). The object allocator 37 then calls a constructor (step 312).That is, processing is performed to create an object and initialize theobject. Note that, according to this operation example, based on thepremise that a plurality of the specialized classes 52 exist, in step304 the most appropriate specialized class 52 among the plurality ofspecialized classes 52 is adopted as the appropriate specialized class52. However, processing can also be performed in which, based on thepremise that only one specialized class 52 exists, in step 304 thespecialized class 52 is adopted as the appropriate specialized class 52if the specialized class 52 is more appropriate than the representativeclass 51.

FIG. 7 is a flowchart illustrating an example of operations of the JVM30 at the time of a garbage collection process in the presentembodiment. Note that, this operation example is executed with respectto the relevant object when the garbage collector 38 takes an object asa target of a garbage collection process. Further, in this case it isassumed that the class of the object that is the target of the garbagecollection process references an array, and that in some cases thespecialized classes 52 reference an array and in some cases thespecialized classes 52 do not reference an array.

When the operations start, in the JVM 30, first the garbage collector 38determines whether or not there is a more appropriate specialized class52 with respect to the value of the relevant object (step 321). Forexample, the aforementioned determination can be performed by checkingwhether or not a specialized class 52 is stored at another addresshaving the same high-order N bits as the high-order N bits of theaddress of the representative class 51, and that the value of the objectsatisfies a condition for using the relevant specialized class 52.

If it is determined that a more appropriate specialized class 52 withrespect to the value of the object does not exist, the garbage collector38 allocates a memory area for storing the object at a movementdestination inside the heap area 32 and copies the contents of theobject to the relevant memory area (step 322). Further, at a movementdestination inside the heap area 32, the garbage collector 38 allocatesa memory area for storing an array that the object references, andcopies the contents of the array to the relevant memory area (step 323).Next, the garbage collector 38 adjusts a pointer so that the object thatis at the movement destination references the array that is at themovement destination (step 324). On the other hand, if it is determinedthat there is a more appropriate specialized class 52 with respect tothe value of the object, the garbage collector 38 selects theappropriate specialized class 52 (step 325). Next, the garbage collector38 allocates a memory area for storing an object of the relevantspecialized class 52 at a movement destination inside the heap area 32and copies the contents of the object to the relevant memory area (step326).

Further, the garbage collector 38 determines whether or not the selectedspecialized class 52 uses an array for holding data (step 327). If it isdetermined that the selected specialized class 52 uses an array forholding data, the garbage collector 38 allocates a memory area forstoring the array that the object of the selected specialized class 52references at a movement destination inside the heap area 32, and copiesthe contents of the array to the memory area (step 323). Next, thegarbage collector 38 adjusts a pointer so that the object of theselected specialized class 52 that is at the movement destinationreferences the array that is at the movement destination (step 324). Incontrast, if it is not determined that the selected specialized class 52uses an array for holding data, the garbage collector 38 copies thecontents of an array that an object at the movement source references tothe object of the specialized class 52 at the movement destination (step328).

According to this operation example, based on the premise that aplurality of the specialized classes 52 exist other than the class ofthe object that is the target of the garbage collection process, in step321 the most appropriate specialized class 52 among the plurality ofspecialized classes 52 is adopted as the appropriate specialized class52. However, processing can also be performed in which, based on thepremise that only one specialized class 52 exists other than the classof the object that is the target of the garbage collection process, instep 321 the relevant specialized class 52 is adopted as the appropriatespecialized class 52 if the relevant specialized class 52 is moreappropriate than the class of the object that is the target of thegarbage collection process.

According to the present embodiment, as illustrated in the operationexamples shown in FIG. 6 and FIG. 7, processing using a more appropriatespecialized class 52 is performed in accordance with an instruction tocreate an object in the JVM 30 or an instruction to perform a garbagecollection process. However, the present embodiment can be made moregeneralized so that processing using a more appropriate specializedclass 52 is performed in accordance with a predetermined instruction inthe JVM 30.

FIG. 8 is a flowchart illustrating an example of operations of the JVM30 when providing class meta information in the present embodiment. Whenthe operations are started, in the JVM 30, first the class loader 36determines whether or not there is a request by a user program toreference class meta information of the specialized class 52 (step 341).When the interpreter 33 or the machine instruction 35 detects aninstruction that requests a reference to class meta information of therepresentative class 51 or the specialized class 52 from a user program(for example, a method of the class 50), the interpreter 33 or themachine instruction 35 conveys information to that effect to the classloader 36, and therefore the aforementioned determination can beperformed based on the conveyed information.

In a case where, as a result, it is not determined that a reference tothe class meta information of the specialized class 52 is requested bythe user program, the processing proceeds directly to step 343. On theother hand, if it is determined that a reference to the class metainformation of the specialized class 52 is requested by the userprogram, the class loader 36 changes the referenced class to therepresentative class 51 with respect to the specialized class 52 (step342). Next, the class loader 36 acquires the data structure (metadatashown in FIG. 2) that holds the class meta information from therepresentative class 51 that the user program designated or from therepresentative class 51 after the change in step 342 (step 343).Thereafter, the class loader 36 extracts the class meta information forwhich the reference was requested from the acquired data structure, andreturns the class meta information to the interpreter 33 or the machineinstruction 35 (step 344).

FIG. 9 is a view illustrating effects of the present embodiment. Here,an example is illustrated in which the java.lang.String class shown inFIG. 3A is taken as the representative class 51, and the three kinds ofspecialized classes 52 shown in FIGS. 3B to 3D are introduced. In FIG.9, results of analyzing a Java® heap dump after running DayTrader for 90minutes are shown in the column with the heading “DayTrader (after 90min run)”. As shown in FIG. 9, when objects in use (live objects) wereextracted, the size of the objects was 562 MB. On the other hand, theestimated memory reduction obtained by introducing the three kinds ofspecialized classes 52 was approximately 60 MB. Further, the estimatedreduction from the Java® heap dump after running SPECjEnterprise for 90minutes are shown in the column with the heading “SPECjEnterprise (after90 min run)”. According to this estimation, it is possible to achieve areduction of approximately 31 MB with respect to the live heap of 373MB. Thus, according to the present embodiment, it is possible to reducethe size of the live heap by approximately 10%. While the presentinvention has been described above using an embodiment, the technicalscope of the present invention is not limited to that of the abovedescribed embodiment. It will be apparent to those skilled in the artthat various changes and substitutions can be made without departingfrom the spirit and scope of the present invention.

What is claimed is:
 1. An apparatus for realizing a runtime system for aclass-based object-oriented programming language, comprising: a storageunit for storing a first class that is an existing class in theobject-oriented programming language, and a second class that is a classthat includes a member that is accessible from outside of the firstclass and that is a class which is specialized for a specific use; and aprocessing unit configured to perform processing using the second classin accordance with a predetermined instruction in software that realizesthe runtime system, and further configured to perform processing usingthe first class in accordance with an instruction to check an identityof the second class in a user program product that is executed by theruntime system.
 2. The apparatus according to claim 1, wherein theprocessing unit includes: a first processing unit configured to performprocessing using the second class in accordance with a predeterminedinstruction in the software that realizes the runtime system; and asecond processing unit configured to perform processing using the firstclass in accordance with an instruction to check an identity of thesecond class in the user program product that is executed by the runtimesystem.
 3. The apparatus according to claim 1, wherein for a classvariable included in the second class that is also included in the firstclass, the second class references the class variable included in thefirst class as a class variable included in the second class.
 4. Theapparatus according to claim 1, wherein as an instance variable that isaccessible from outside the second class, the second class includes aninstance variable with respect to which a relative arrangement positionin the second class is identical to a relative arrangement position inthe first class.
 5. The apparatus according to claim 1, wherein as aninstance method that is accessible from outside the second class, thesecond class includes an instance method with respect to which an indexin a method table of the second class is identical to an index in amethod table of the first class.
 6. The apparatus according to claim 2,wherein the predetermined instruction is an instruction to create aninstance of a class group comprising the first class and the secondclass; and the first processing unit is configured to create an instanceof the second class in a case where it is determined that the secondclass is appropriate based on a value stored in the instance to becreated, and wherein the first processing unit is configured to createan instance of the first class in a case where it cannot be determinedthat the second class is appropriate based on a value stored in theinstance to be created.
 7. The apparatus according to claim 2, whereinthe predetermined instruction is an instruction to perform a garbagecollection with respect to a memory for storing an instance of the firstclass; and the first processing unit is configured to convert aninstance of the first class to an instance of the second class inresponse to determining that the second class is appropriate based on avalue stored in the first class.
 8. An apparatus for realizing a Java®runtime system, the apparatus comprising: a storage unit for storing afirst class that is an existing class in Java®, and a second class thatis a class that includes a member that does not have a private attributeof the first class and is a class in which a size of a field of thefirst class is reduced in accordance with a value stored in the firstclass; and a processing unit configured to process a predeterminedinstruction in software that realizes the runtime system using thesecond class, and further configured to perform processing that returnsinformation that the first class holds in accordance with a technique ina user program product that is executed by the runtime system.
 9. Theapparatus according to claim 8, wherein the technique is an “instanceof”bytecode that takes an instance of the second class as an argument. 10.The apparatus according to claim 8, wherein the technique is a“checkcast” bytecode that takes an instance of the second class as anargument.
 11. The apparatus according to claim 8, wherein the techniqueis a “Class.getName( )” method that takes the second class as anargument.
 12. A computer implemented method executed for realizing aruntime system for a class-based object-oriented programming language,the method comprising: preparing a first class that is an existing classin the object-oriented programming language, and a second class that isa class that includes a member that is accessible from outside of thefirst class and that is a class which is specialized for a specific use;performing processing using the second class in accordance with apredetermined instruction in software that realizes the runtime system;and performing processing using the first class in accordance with aninstruction to check an identity of the second class in a user programproduct that is executed by the runtime system.
 13. The method accordingto claim 12, wherein for a class variable included in the second classthat is also included in the first class, the second class referencesthe class variable included in the first class as a class variableincluded in the second class.
 14. The method according to claim 2,wherein as an instance variable that is accessible from outside thesecond class, the second class includes an instance variable withrespect to which a relative arrangement position in the second class isidentical to a relative arrangement position in the first class.
 15. Themethod according to claim 12, wherein as an instance method that isaccessible from outside the second class, the second class includes aninstance method with respect to which an index in a method table of thesecond class is identical to an index in a method table of the firstclass.
 16. The method according to claim 12, wherein the predeterminedinstruction is an instruction to create an instance of a class groupcomprising the first class and the second class; and wherein the methodfurther comprises creating an instance of the second class in a casewhere it is determined that the second class is appropriate based on avalue stored in the instance to be created.
 17. The method according toclaim 12, wherein the predetermined instruction is an instruction toperform a garbage collection with respect to a memory for storing aninstance of the first class; and wherein the method further comprisesconverting an instance of the first class to an instance of the secondclass in a case where it is determined that the second class isappropriate based on a value stored in the first class.
 18. The methodaccording to claim 12, wherein the first class comprises ajavamath.BigInteger class.
 19. The method according to claim 12, whereinperforming processing using the second class further comprises storing abit string having a bit length less than
 128. 20. The method accordingto claim 19, wherein the second class comprises a 32-bit fieldcontaining the bit length of the bit string and a length until a firstnon-zero bit appears in the bit string.